## STUDY 1 ANALYSIS AND DATA VISUALIZATION

metoo1 <- read.csv("study1_replication_analysis.csv")

### REGRESSION RESULTS SUPPLEMENTARY MATERIAL S6: NUMERICAL RESULTS STUDY 1: RESIGNATION -- TABLE S6.1

library(broom)
library(purrr)
library(ggplot2)
library(sjPlot)
library(ggpubr)
library(patchwork)

run_m1 <- function(scandal_sub) {
  m1 <- lm(resign ~ denial + scandal_party_congruence, data = scandal_sub)
  tidy_out <- tidy(m1)
  glance_out <- glance(m1)
  sub_info <- unique(scandal_sub$scandal_sex)
  mean_ser <- mean(scandal_sub$seriousness, na.rm=T)
  return(cbind(sub_info, tidy_out[, c("term", "estimate", "std.error", "p.value")], glance_out[, c("r.squared", "nobs")], mean_ser))
}

m1_res <- map_df(split(metoo1, metoo1$scandal_sex), run_m1)

print(m1_res)


metoo1$scandal_party_congruence <- as.factor(metoo1$scandal_party_congruence)

run_m1_party <- function(scandal_sub) {
  m1_party <- lm(resign ~ denial, data = scandal_sub)
  tidy_out <- tidy(m1_party)
  glance_out <- glance(m1_party)
  sub_info <- unique(scandal_sub[, c("scandal_sex", "scandal_party_congruence")])
  return(cbind(sub_info, tidy_out[, c("term", "estimate", "std.error", "p.value")], glance_out[, c("r.squared", "nobs")]))
}

m1_res_party <- map_df(split(metoo1, list(metoo1$scandal_sex, metoo1$scandal_party_congruence)), run_m1_party)

print(m1_res_party)


### REGRESSION RESULTS SUPPLEMENTARY MATERIAL S6: NUMERICAL RESULTS STUDY 1: BELIEFS -- TABLE S6.2

metoo1$response <- as.factor(metoo1$response)
metoo1 <- within(metoo1, response <- relevel(response, ref = "prior")) 

run_m2 <- function(scandal_sub) {
  m2 <- lm(likely ~ response + scandal_party_congruence, data = scandal_sub)
  tidy_out <- tidy(m2)
  glance_out <- glance(m2)
  sub_info <- unique(scandal_sub$scandal_sex)
  return(cbind(sub_info, tidy_out[, c("term", "estimate", "std.error", "p.value")], glance_out[, c("r.squared", "nobs")]))
}

m2_res <- map_df(split(metoo1, metoo1$scandal_sex), run_m2)

print(m2_res)



### MAIN TEXT: FIGURE 1: Scandal type, incumbent response and citizen attitudes (Study 1)

set_theme(base = theme_classic(), #To remove the background color and the grids  #To change the font typ
          axis.title.size = 1,  #To change axis title size
          axis.textsize.x = 1,  #To change x axis text size
          axis.textsize.y = 1)

re_order <- c("affair", "harassment", "sexting", "assault", "rape")
metoo1$scandal_sex <- factor(metoo1$scandal_sex, levels = re_order)

serious_line <- ggline(metoo1, 
                       x = "scandal_sex", y = "seriousness",
                       xlab = "",
                       ylab = "Seriousness",
                       add = "mean_ci", error.plot = "linerange", palette = "Dark2", 
                       ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1.5, 
                       point.size = 17, position = position_dodge(0.1), title = "")  + 
  theme(legend.position="none") +
  coord_cartesian(ylim=c(40,80))  +
  theme(text = element_text(size=40))  +
  scale_x_discrete(labels=c("affair" = "Affair",  "harassment" = "Harassment", "sexting" = "Sexting",
                            "assault" = "Assault", "rape" = "Rape")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 45, angle = 22),
        axis.text.y = element_text(color = "grey20", size = 45),
        axis.title.x = element_text(color = "grey20", size = 45),
        axis.title.y = element_text(color = "grey20", size = 45))

belief_line <- ggline(metoo1, 
                      x = "scandal_sex", y = "likely", color = "response",
                      xlab = "Scandal Condition",
                      ylab = "Belief in Allegation",
                      add = "mean_ci", error.plot = "linerange", palette = "Dark2", 
                      ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1.5,
                      point.size = 17, position = position_dodge(0.1), title = "")  + 
  theme(legend.position="bottom") + labs(color = "") +
  coord_cartesian(ylim=c(40,80))  +
  theme(text = element_text(size=40)) +
  scale_x_discrete(labels=c("affair" = "Affair",  "harassment" = "Harassment", "sexting" = "Sexting",
                            "assault" = "Assault", "rape" = "Rape")) + 
  scale_color_grey(start=0.7, end=0.2) + theme(legend.position = c(0.5, 0.1), legend.text = element_text(color = "black", size = 42),
                                               legend.direction="horizontal") + 
  theme(axis.text.x = element_text(color = "grey20", size = 45, angle = 22),
        axis.text.y = element_blank(),
        axis.title.x = element_text(color = "grey20", size = 45),
        axis.title.y = element_text(color = "grey20", size = 45)) + 
  scale_colour_manual(labels = c("Apology", "Denial", "Prior"),
                      values = c("grey70", "grey45", "grey20"))
belief_line

resign_line <- ggline(metoo1, 
                      x = "scandal_sex", y = "resign", color = "communication",
                      xlab = "",
                      ylab = "Resignation",
                      add = "mean_ci", error.plot = "linerange", palette = "Dark2", 
                      ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1.5,
                      point.size = 17, position = position_dodge(0.1), title = "")  + 
  theme(legend.position="") +
  coord_cartesian(ylim=c(40,80))  +
  theme(text = element_text(size=40)) +
  scale_x_discrete(labels=c("affair" = "Affair",  "harassment" = "Harassment", "sexting" = "Sexting",
                            "assault" = "Assault", "rape" = "Rape")) +
  scale_color_grey(start=0.7, end=0.50) + 
  theme(axis.text.x = element_text(color = "grey20", size = 45, angle = 22),
        axis.text.y = element_blank(),
        axis.title.x = element_text(color = "grey20", size = 45),
        axis.title.y = element_text(color = "grey20", size = 45))
resign_line

serious_line | belief_line | resign_line

#ggsave("fig1.png", width = 30, height = 13, dpi = 600) 



### SUPPLEMENTARY MATERIAL S7: Partisan Effects: Study 1 -- Baseline Differences by Partisanship -- FIGURE S7.1

## serious (prior)

metoo1_party <- metoo1 %>% filter(scandal_party_congruence != "control")
metoo1_party_prior <- metoo1_party %>% filter(response == "prior")

mean(metoo1_party_prior$likely[metoo1_party_prior$scandal_party_congruence == "copartisan"])
mean(metoo1_party_prior$likely[metoo1_party_prior$scandal_party_congruence == "outpartisan"])

serious_party <- ggline(metoo1_party_prior, ## prior diff withour comm
                        x = "scandal_sex", y = "seriousness", color="scandal_party_congruence",
                        xlab = "",
                        ylab = "Seriousness (prior)",
                        add = "mean_se", error.plot = "linerange", palette = "Dark2", 
                        ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1, 
                        point.size = 2, title = "")  + 
  theme(legend.position="none") +
  coord_cartesian(ylim=c(45,80)) +
  scale_x_discrete(labels=c("1" = "Affair",  "2" = "Harassment", "3" = "Sexting",
                            "4" = "Assault", "5" = "Rape")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 10, angle = 22),
        axis.text.y = element_text(color = "grey20", size = 10),
        axis.title.x = element_text(color = "grey20", size = 10),
        axis.title.y = element_text(color = "grey20", size = 10)) + 
  scale_color_manual(labels = c("Copartisan", "Outpartisan"), 
                     values = c("grey55", "black")) + 
  labs(color="Party")


serious_party

## belief (prior)

belief_party <- ggline(metoo1_party_prior, ## prior differences without comm.
                       x = "scandal_sex", y = "likely", color="scandal_party_congruence",
                       xlab = "",
                       ylab = "Belief in Allegation (prior)",
                       add = "mean_se", error.plot = "linerange", palette = "Dark2", 
                       ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1, 
                       point.size = 2, title = "")  + 
  theme(legend.position=c(0.5, 0.1), legend.direction = "horizontal") +
  coord_cartesian(ylim=c(45,80)) +
  scale_x_discrete(labels=c("1" = "Affair",  "2" = "Harassment", "3" = "Sexting",
                            "4" = "Assault", "5" = "Rape")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 10, angle = 22),
        axis.text.y = element_text(color = "grey20", size = 10),
        axis.title.x = element_text(color = "grey20", size = 10),
        axis.title.y = element_text(color = "grey20", size = 10)) + 
  scale_color_manual(labels = c("Copartisan", "Outpartisan"), 
                     values = c("grey55", "black")) + 
  labs(color="Party")


belief_party

## resign

resign_party <- ggline(metoo1_party, ## all obs (always post-comm)
                       x = "scandal_sex", y = "resign", color="scandal_party_congruence",
                       xlab = "",
                       ylab = "Resignation",
                       add = "mean_se", error.plot = "linerange", palette = "Dark2", 
                       ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1, 
                       point.size = 2, title = "")  + 
  theme(legend.position="none") +
  coord_cartesian(ylim=c(45,80)) +
  scale_x_discrete(labels=c("1" = "Affair",  "2" = "Harassment", "3" = "Sexting",
                            "4" = "Assault", "5" = "Rape")) + 
  theme(axis.text.x = element_text(color = "grey20", size = 10, angle = 22),
        axis.text.y = element_text(color = "grey20", size = 10),
        axis.title.x = element_text(color = "grey20", size = 10),
        axis.title.y = element_text(color = "grey20", size = 10)) + 
  scale_color_manual(labels = c("Copartisan", "Outpartisan"), 
                     values = c("grey55", "black")) + 
  labs(color="Party")


resign_party


serious_party | belief_party | resign_party

#ggsave("fig_s7_1.png", width = 10, height = 4, dpi = 600) 




### SUPPLEMENTARY MATERIAL S7: Partisan Effects: Study 1 -- Differences in Communication Effects by Partisanship --  FIGURE S7.2


## for post-comm belief differences (left panel)

metoo1_post <- metoo1_party %>% filter(response != "prior") ## only post-comm elicited beliefs! 

lm_affair_co_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "affair" & 
                                                      scandal_party_congruence == "copartisan"))
lm_affair_out_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "affair" & 
                                                       scandal_party_congruence == "outpartisan"))
lm_harr_co_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "harassment" & 
                                                    scandal_party_congruence == "copartisan"))
lm_harr_out_b <- lm(likely ~ denial, data = subset(metoo1, scandal_sex== "harassment" & 
                                                     scandal_party_congruence == "outpartisan"))
lm_ting_co_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "sexting" & 
                                                    scandal_party_congruence == "copartisan"))
lm_ting_out_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "sexting" & 
                                                     scandal_party_congruence == "outpartisan"))
lm_ass_co_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "assault" & 
                                                   scandal_party_congruence == "copartisan"))
lm_ass_out_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "assault" & 
                                                    scandal_party_congruence == "outpartisan"))
lm_rape_co_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "rape" & 
                                                    scandal_party_congruence == "copartisan"))
lm_rape_out_b <- lm(likely ~ denial, data = subset(metoo1_post, scandal_sex== "rape" & 
                                                     scandal_party_congruence == "outpartisan"))

## for post-comm resignation differences (right panel)

lm_affair_co <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "affair" & 
                                                    scandal_party_congruence == "copartisan"))
lm_affair_out <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "affair" & 
                                                     scandal_party_congruence == "outpartisan"))
lm_harr_co <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "harassment" & 
                                                  scandal_party_congruence == "copartisan"))
lm_harr_out <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "harassment" & 
                                                   scandal_party_congruence == "outpartisan"))
lm_ting_co <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "sexting" & 
                                                  scandal_party_congruence == "copartisan"))
lm_ting_out <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "sexting" & 
                                                   scandal_party_congruence == "outpartisan"))
lm_ass_co <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "assault" & 
                                                 scandal_party_congruence == "copartisan"))
lm_ass_out <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "assault" & 
                                                  scandal_party_congruence == "outpartisan"))
lm_rape_co <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "rape" & 
                                                  scandal_party_congruence == "copartisan"))
lm_rape_out <- lm(resign ~ denial, data = subset(metoo1, scandal_sex== "rape" & 
                                                   scandal_party_congruence == "outpartisan"))



set_theme(base = theme_bw(), #To remove the background color and the grids  #To change the font typ
          axis.title.size = 1,  #To change axis title size
          axis.textsize.x = 1,  #To change x axis text size
          axis.textsize.y = 1)

belief_d_party <- plot_models(lm_affair_co_b, lm_affair_out_b, lm_harr_co_b, lm_harr_out_b, lm_ting_co_b, lm_ting_out_b,
                              lm_ass_co_b, lm_ass_out_b, lm_rape_co_b, lm_rape_out_b, show.values = FALSE,
                              title = "Post-Communication Belief in Allegation",
                              vline.color = "black",
                              axis.labels = c("Denial"),
                              dot.size=5, line.size=1.3, value.size = 4, colors= "gs", show.legend = TRUE, axis.lim = c(-30,30),
                              robust=TRUE) + theme_bw() +
  theme(text = element_text(size=12)) + theme(legend.position = "none",  legend.text = element_text(color = "black", size = 12),
                                              legend.direction="vertical") + 
  theme(axis.text.x = element_text(color = "black", size = 12),
        axis.text.y = element_text(color = "black", size = 12),
        axis.title.x = element_text(color = "black", size = 12),
        axis.title.y = element_text(color = "black", size = 12)) + 
  scale_color_manual(labels = c("Rape Outpartisan", "Rape Copartisan", "Assault Outpartisan", "Assault Copartisan", "Sexting Outpartisan", 
                                "Sexting Copartisan", "Harrassment Outpartisan", "Harrassment Copartisan", 
                                "Affair Outpartisan", "Affair Copartisan"), 
                     values = c("red", "red", "orange","orange", "grey36",
                                     "grey36", "grey48","grey48", "grey60", "grey60")) + 
                                       labs(color="Scandal and Party Cue Type")
belief_d_party

denial_party <- plot_models(lm_affair_co, lm_affair_out, lm_harr_co, lm_harr_out, lm_ting_co, lm_ting_out,
                            lm_ass_co, lm_ass_out, lm_rape_co, lm_rape_out, show.values = FALSE,
                            title = "Post-Communication Resignation Support",
                            vline.color = "black",
                            axis.labels = c("Denial"),
                            dot.size=5, line.size=1.3, value.size = 4, colors= "gs", show.legend = TRUE, axis.lim = c(-30,30),
                            robust=TRUE) + theme_bw() +
  theme(text = element_text(size=12)) + theme(legend.position = c(0.7, 0.5),  legend.text = element_text(color = "black", size = 12),
                                              legend.direction="vertical") + 
  theme(axis.text.x = element_text(color = "black", size = 12),
        axis.text.y = element_text(color = "black", size = 12),
        axis.title.x = element_text(color = "black", size = 12),
        axis.title.y = element_text(color = "black", size = 12)) + 
  scale_color_manual(labels = c("Rape Outpartisan", "Rape Copartisan", "Assault Outpartisan", "Assault Copartisan", "Sexting Outpartisan", 
                                "Sexting Copartisan", "Harrassment Outpartisan", "Harrassment Copartisan", 
                                "Affair Outpartisan", "Affair Copartisan"), 
                     values = c("red", "red","orange","orange", "grey36",
                                     "grey36", "grey48","grey48","grey60", "grey60")) + 
                                       labs(color="Scandal and Party Cue Type") +
  scale_shape_manual(values=c(0:10))
denial_party

belief_d_party | denial_party

#ggsave("fig_s7_2.png", width = 14, height = 6, dpi = 600) 


## S8: Effects by Respondent-Level Seriousness: Study 1 -- FIGURE S8

## REGRESSION RESULTS

metoo1$serious_bin <- NA
metoo1$serious_bin[metoo1$seriousness < 20] <- "0-20"
metoo1$serious_bin[metoo1$seriousness >= 20 & metoo1$seriousness < 40] <- "20-40"
metoo1$serious_bin[metoo1$seriousness >= 40 & metoo1$seriousness < 60] <- "40-60"
metoo1$serious_bin[metoo1$seriousness >=60 & metoo1$seriousness < 80] <- "60-80"
metoo1$serious_bin[metoo1$seriousness >= 80] <- "80-100"
metoo1$serious_bin <- factor(metoo1$serious_bin, levels=c("0-20", "20-40", "40-60", "60-80", "80-100"))

comm_individual_ser <- ggline(metoo1, 
                                         x = "serious_bin", y = "resign", color = "communication",
                                         xlab = "Perceived Seriousness",
                                         ylab = "Resignation",
                                         add = "mean_ci", error.plot = "linerange", palette = "Dark2", 
                                         ggtheme = theme_bw(), plot_type = "b", linetype = "solid", size = 1,
                                         point.size = 2.5, position = position_dodge(0.1), title = "",
                                         nrow = 1) +
  theme(legend.position = c(0.5, 0.1), legend.text = element_text(color = "black", size = 22),
        legend.direction="horizontal") +
  coord_cartesian(ylim=c(0,100))  +
  theme(text = element_text(size=18)) +
  scale_color_grey(start=0.7, end=0.45)

comm_individual_ser

#ggsave("fig_s8.png", width = 10, height = 7, dpi = 600)

